﻿@using Covenant.Models.Listeners
@model IEnumerable<Listener>

<div class="table-responsive">
    <table id="listeners-table" class="table table-hover">
        <thead>
            <tr>
                <th>@Html.DisplayNameFor(model => model.Name)</th>
                <th>@Html.DisplayNameFor(model => model.ListenerType)</th>
                <th>@Html.DisplayNameFor(model => model.Status)</th>
                <th>@Html.DisplayNameFor(model => model.StartTime)</th>
                <th>@Html.DisplayNameFor(model => model.ConnectAddresses)</th>
                <th>@Html.DisplayNameFor(model => model.ConnectPort)</th>
            </tr>
        </thead>
        <tbody>
            @foreach (var item in Model)
            {
                @if (item.Status != ListenerStatus.Uninitialized)
                {
                    <tr>
                        <td>
                            <a asp-controller="Listener" asp-action="interact" asp-route-id="@item.Id">
                                @Html.DisplayFor(modelItem => item.Name)
                            </a>
                        </td>
                        <td>@Html.DisplayFor(modelItem => item.ListenerType.Name)</td>
                        <td>@Html.DisplayFor(modelItem => item.Status)</td>
                        <td>@Html.DisplayFor(modelItem => item.StartTime)</td>
                        @{ var connectaddresses = string.Join(",", item.ConnectAddresses); }
                        <td>@Html.DisplayFor(modelItem => connectaddresses)</td>
                        <td>@Html.DisplayFor(modelItem => item.ConnectPort)</td>
                    </tr>
                }
            }
        </tbody>
    </table>
</div>